#include<bits/stdc++.h>
using namespace std;
const int mod = 998244353;
long long qmi(long long a,int b)
{
	long long res = 1;
	while(b)
	{
		if(b & 1) (res *= a) %= mod;
		(a *= a) %= mod;
		b >>= 1;
	}
	return res;
}
bool vis[1000003];
int n;
int x[1403],r[1403],g[1403];
long long Lcm = 1,ny;
bool flag = 1;
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0),cout.tie(0);
	freopen("traffic.in","r",stdin);
	freopen("traffic.out","w",stdout);
	cin >> n;
	for(int i = 1;i <= n;i++)
	{
		cin >> x[i] >> r[i] >> g[i];
		if(flag)
		{
			Lcm = Lcm * (r[i] + g[i]) / __gcd(Lcm,0ll + r[i] + g[i]);
			if(Lcm > 1000000)
				flag = 0;
		}
	}
	ny = qmi(Lcm,mod - 2);
	if(flag)
	{
		for(int i = 0;i < Lcm;i++)
			vis[i] = 1;
		n++;
		x[n] = 0,r[n] = 1,g[n] = 0;
		for(int i = 1;i <= n;i++)
		{
			x[i] = (Lcm - x[i] % Lcm) % Lcm;
			int ans = 0,k = r[i] + g[i];
			for(int t = 0;t < Lcm;t += k)
			{
				for(int c = 0;c < r[i];c++)
				{
					int p = t + c + x[i];
					p %= Lcm;
					ans += vis[p];
					vis[p] = 0;
				}
			}
			cout << ans * ny % mod << "\n";
		}
		return 0;
	}
	return 0;
}